package com.example.aop;

import com.example.annotation.RecordUserLog;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author code威
 * @version 1.0
 * @description: recordUserLog注解增强
 * @date 2022/1/3 16:31
 */
@Aspect
@Component
public class RecordUserLogAOP {

    private static final Logger log = LoggerFactory.getLogger(RecordUserLogAOP.class);

    @Before("@annotation(recordUserLog)")
    public void before(JoinPoint joinPoint, RecordUserLog recordUserLog){
        Object[] args = joinPoint.getArgs();
        log.info("当前的用户姓名为："+recordUserLog.userName()+",当前的操作是"+recordUserLog.operate());


    }
}
